#!/usr/bin/env node

const fs  = require('fs');
const src = process.argv[2],
      dst = process.argv[3],
      err = console.error;

if(!fs.existsSync(src)){
  err('%s not exits',src);
  process.exit(1);
}

if(!fs.statSync(src).isFile()){
  err('%s is not file',src);
  process.exit(2);
}
if(typeof dst ==='undefined'){
  err('dst is undefined');
}

let stm = fs.createReadStream(src).pipe(fs.createWriteStream(dst));

//没有下面赋予权限的语句，可以在命令行中写node abc.js 来执行
/*赋予权限
stm.on('close',()=>{
  fs.chmodSync(dst,fs.statSync(src).mode);
})*/
